package ai4games_tests.soccer;

import game2dai.World;
import game2dai.entities.BaseEntity;
import game2dai.fsm.State;
import game2dai.fsm.Telegram;

public class PitchGlobal extends State implements Constants {

	private static PitchGlobal instance = null;	

	public static PitchGlobal state(){
		if(instance == null){
			instance = new PitchGlobal();
			instance.name = "Game On";
		}
		return instance;
	}

	@Override
	public void enter(BaseEntity owner) {
	}

	@Override
	public void execute(BaseEntity owner, double deltaTime, World world) {
		Pitch pitch = (Pitch) owner;
		if(pitch.sw.getRunTime() >= MATCH_TIME){
			pitch.sw.reset();
			pitch.FSM().changeState(PitchPlayersOff.state());
		}
	}

	@Override
	public void exit(BaseEntity owner) {
	}

	@Override
	public boolean onMessage(BaseEntity owner, Telegram tgram) {
		return false;
	}

}
